import tensorflow as tf




# 保存模型时不能只保存权重！！！
# model = tf.keras.models.load_model('logs/ep005-loss2.898-val_loss2.859.h5')
# converter = tf.compat.v1.lite.TFLiteConverter.from_keras_model_file('logs/ep005-loss2.898-val_loss2.859.h5')
converter = tf.lite.TFLiteConverter.from_saved_model('logs/ep001-loss2.921-val_loss2.862')
converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
lite_model = converter.convert()

# Save the model.
with open('model1.tflite', 'wb') as f:
  f.write(lite_model)
